﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Customer_Profile.eCard.DBDao;
using KVB.Common;

namespace Customer_Profile.eCard
{
    public partial class addcflow : System.Web.UI.Page
    {
        string card_no = "";
        string deal_no = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["CARDNO"] != null)
            {
                card_no = Request["CARDNO"].ToString();
            }
            if (Request["dealno"] != null)
            {
                deal_no = Request["dealno"].ToString();
            }
            txtCardNo.Value = card_no;
            if(!Page.IsPostBack)
            {
                Comm.BindDll(ref dropCflowType, "cflow_type", false, "");
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime cflow_date = DateTime.Parse(txtCflowDate.Value.ToString());
                //string cparty_id = txtCpartyID.Value;
                decimal amount = decimal.Parse(txtAmount.Value.ToString());
                string cflow_status = dropCflowStatus.SelectedItem.Value;
                string cflow_type = dropCflowType.SelectedItem.Value;
                string remark = txtRemark.Value;

                bool bok = CflowDao.AddCflow(card_no, cflow_date, amount, cflow_status, cflow_type, remark,deal_no);
                if (bok)
                    Response.Write("<script language=javascript>alert('success');</script>");
                else
                    Response.Write("<script language=javascript>alert('error');</script>");
            }
            catch (Exception ex)
            {
                Log.WriteDefaultLog("addcflow.btnSave_Click", ex.ToString());
                Response.Write("<script language=javascript>alert('Error!');</script>");
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("cflowSearchList.aspx?CARDNO=" + card_no + "&dealno="+deal_no);
        }
    }
}